<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<div class="loading-container" [ngClass]="{'modify-container': !!isModify}">
    <ng-container
        *ngIf="[dataMap.System_Init_Status.running.value, dataMap.networkModifyStatus.running.value].includes(status)">
        <img [src]="getInitLoadingImg()">
        <div [innerHTML]="init_running_label | i18n: [result.rate || 0]"></div>
    </ng-container>

    <ng-container
        *ngIf="[dataMap.System_Init_Status.archiveFailed.value,dataMap.System_Init_Status.backupFailed.value,dataMap.System_Init_Status.authFailed.value,dataMap.System_Init_Status.failed.value].includes(status)">
        <img [src]="getInitFailedImg()">
        <div [innerHTML]="result.code | i18n : result.params"></div>
        <div *ngIf="dataMap.System_Init_Status.archiveFailed.value !== status" class="btn-container">
            <ng-container *ngTemplateOutlet="resetTpl"></ng-container>
        </div>
        <div *ngIf="dataMap.System_Init_Status.archiveFailed.value === status" class="btn-container">
            <ng-container *ngTemplateOutlet="exportLogTpl"></ng-container>
        </div>
    </ng-container>

    <!-- 修改网络时使用 -->
    <ng-container *ngIf="dataMap.networkModifyStatus.fail.value === status">
        <img [src]="getInitFailedImg()">
        <div [innerHTML]="result.code | i18n : result.params"></div>
        <button lv-button lvType='primary' (click)='modifyReset()' style="margin-top:8px">
            {{'common_modify_config_label' | i18n}}
        </button>
    </ng-container>

</div>

<ng-template #resetTpl>
    <lv-group lvGutter="16px">
        <button lv-button lvType='primary' (click)='reset()'>
            {{'common_modify_config_label' | i18n}}
        </button>
        <button lv-button (click)='exportLog()'>
            {{'common_export_log_label' | i18n}}
        </button>
    </lv-group>
</ng-template>

<ng-template #exportLogTpl>
    <button lv-button lvType='primary' lv-button (click)='exportLog()'>
        {{'common_export_log_label' | i18n}}
    </button>
</ng-template>

<ng-template #fileDownloadCompletedTpl>
    <div id="file-download-completed" [innerHTML]="fileDownloadCompletedLabel"></div>
</ng-template>